<html><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>我的课程笔记</title>
    <link rel="stylesheet" type="text/css" th:href="@{css1/css.css}"  />
    <style type="text/css">
        .show-note{
            background-color: white;
            position: absolute;
            width:800px;
            height:100%;
            left:40%;
            top:10%;
            padding-top: 150px;
            padding-left: 100px;
            margin-left:-200px;
            margin-top:-100px;
        }

        table{
            padding-top: 10px;
            padding-left: 20px;
            padding-right: 20px;
            padding-bottom: 20px;
            background-color: rgb(211,211,211);

        }
    </style>
</head>

<body>
<div class="wrap clearfix">
    <!-- left nav start -->
    <div class="index_left fl">
        <div th:align="center"><img class="u_img" width="100px" height="100px" th:src="@{${user.img_src}} "></div>
        <p class="p" style="text-align: center" th:text="${user.name}">用户名</p>
        <div class="nav">
            <ul>
                <li><a href="shouye" >首页</a></li>
                <li><a href="index" >课程浏览</a></li>
                <li><a href="list" >我的课程</a></li>
                <li><a href="show" >笔记</a></li>
                <li><a href="contact" >设置</a></li>
            </ul>
        </div>
    </div>
    <!-- left nav end-->

    <!--right-->
    <div class="show_right fr">
        <div class="show-note">
            <table>
                <thead>
                <tr>
                    <th colspan="2">课程名称</th>
                    <th></th>
                    <th>笔记内容</th>
                </tr>
                </thead>
                <tbody>
                <tr th:each="p: ${notes}">
                    <td  colspan="2" th:text="${p.cname}"></td>
                    <td></td>
                    <td th:text="${p.note}"></td>
                    <td><button type="button" th:id="${p.id}" onclick="delete_note(this)">删除</button></td>
                </tr>
                </tbody>
            </table>
        </div>
    </div>
</div>
<script src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
<script type="text/javascript">
    function delete_note(self) {
        $.ajax({
            type:'POST',
            url:'delete_note',
            data:{"id":self.getAttribute('id')},
            dataType:'int',
            traditional:true,
            success:function (data) {
                if(data==1){
                    alert("删除笔记成功！");
                    window.location.href="http://localhost:8080/show"
                }

            },
            error:function (XMLHttpRequest,textStatus,errorThrow) {
                alter("删除笔记失败，请检查网络");
                alter(XMLHttpRequest.status);
                alter(XMLHttpRequest.readyState);
                alter(textStatus);

            }
        })
    }
</script>
</body>
</html>
